package com.jy.wms.common.base;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by Administrator on 2017-12-27.
 */
public class TimeGeneration {
    /**
     * 开始时间
     *
     * @param startTime
     * @return
     */
    public static String startTime(String startTime) {
        String cjsj_start = null;
        if (startTime != null && !"".equals(startTime)) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Calendar c = Calendar.getInstance();
            c.setTime(new Date(Long.valueOf(startTime)));
            c.set(Calendar.HOUR_OF_DAY, 00);
            c.set(Calendar.MINUTE, 00);
            c.set(Calendar.SECOND, 00);
            cjsj_start = sdf.format(c.getTime());
        }
        return cjsj_start;
    }

    /**
     * 结束时间
     *
     * @param endTime
     * @return
     */
    public static String endTime(String endTime) {
        String cjsj_end = null;
        if (endTime != null && !"".equals(endTime)) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Calendar c = Calendar.getInstance();
            c.setTime(new Date(Long.valueOf(endTime)));
            c.set(Calendar.HOUR_OF_DAY, 23);
            c.set(Calendar.MINUTE, 59);
            c.set(Calendar.SECOND, 59);
            cjsj_end = sdf.format(c.getTime());
        }
        return cjsj_end;
    }
}
